home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / atcp_finger.lha / finger / amiga.c next >
C/C++ Source or Header  |  1993-08-10  |  598b  |  41 lines

  1. /*
  2.  * This is only for the GNU C Compiler.
  3.  */
  4.  
  5. #include <bsdsocket.h>
  6. #include <sys/types.h>
  7. #include <signal.h>
  8. #include <exec/libraries.h>
  9. #include <dos/dosextens.h>
  10. #include <dos/dos.h>
  11. #include <sys/time.h>
  12.  
  13. int sgetc(int sock)
  14. {
  15.     unsigned char c;
  16.     fd_set rd,ex;
  17.     long flgs;
  18.     int n;
  19.  
  20.     struct timeval t;
  21.     t.tv_sec = 10L;
  22.     t.tv_usec = 0;
  23.  
  24.     FD_ZERO(&rd);
  25.     FD_ZERO(&ex);
  26.  
  27.     FD_SET(sock,&rd);
  28.     FD_SET(sock,&ex);
  29.     flgs = SIGBREAKF_CTRL_D;
  30.     
  31.     WaitSelect(16,&rd,0L,&ex,&t,&flgs);
  32.     if (FD_ISSET(sock,&rd))
  33.     {    n = recv(sock, &c, 1, 0);
  34.         if (n == 1)
  35.             return c;
  36.         else return -1;
  37.     }
  38.  
  39.     else return -1;
  40. }
  41.